require 'watir'
include Watir
require 'test/unit'
require 'test/unit/ui/console/testrunner'
require 'watir/testUnitAddons'
require 'watir/testcase'
require 'watir/contrib/enabled_popup'
class TC_Photos < Test::Unit::TestCase
  def test_12
    gallery = "aaaaaxxxxxx"
    $ie.goto($UniVar)
    $ie.refresh()

    $ie.link(:text, 'Control Panel').click
    $ie.link(:text, 'Administration').click
    $ie.table(:index, 5).click
    $ie.link(:index, 13).click
    $ie.text_field(:index, 1).value = gallery
    $ie.text_field(:index, 2).value = gallery
    $ie.link(:text, 'Save').flash
    $ie.link(:text, 'Save').click
    $ie.link(:text, 'Exit Control Panel and Return to Site').click
    
    $ie.link(:text, 'Control Panel').click
    $ie.link(:text, 'My Photos').click
    $ie.table(:index, 8).click
    $ie.link(:text, 'Advanced Photo Settings').click
    $ie.div(:index, 55).click
    $ImagePath = "C:\\Program Files\\Telligent\\Community Server 2.1\\Web\\Emoticons\\emoticons.gif"
    $ie.file_field(:index, 1).set($ImagePath)
    $ie.wait()
    $ie.link(:text, 'Save').click
    $ie.wait()
    assert($ie.image(:src, 'http://localhost/cs/photos/sample/images/watermark.aspx').exists?)
    
    $ie.link(:text, 'Administration').click
    $ie.table(:index, 5).click
    $ie.link(:index, 15).click
    $ie.link(:text, 'Delete').click_no_wait
    hwnd = $ie.enabled_popup(20)
      if(hwnd)
      w = WinClicker.new
      w.clickWindowsButton_hwnd(hwnd, "OK")
      end     
    assert(!$ie.link(:text, gallery).exists?)
  end
end